package com.xy.novelweb.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration
@Slf4j
public class ErrorPageConfig {
		/**
		 * SpringBoot2.0以上版本WebServerFactoryCustomizer代替之前版本的EmbeddedWebServerFactoryCustomizerAutoConfiguration
		 *
		 * @return
		 */
		@Bean
		public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
				log.info("ErroPage注入");
				return (factory -> {
						ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/static/404.html");
						factory.addErrorPages(errorPage404);
				});
		}

}